package com.lab.idea.bl.pool;

import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONObject;
import cn.hutool.system.SystemUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * 日志输出助手
 * @author mao
 */
@Slf4j
public class LabThreadPrintHelper {

    private static final String SPLIT = "----------------%s----------------";

    private static final String LINEARISED = SystemUtil.getOsInfo().getLineSeparator();

    public static String format(String title, JSONObject info){
        StringBuilder builder = new StringBuilder(LINEARISED);
        builder.append(String.format(SPLIT,title)).append(LINEARISED);
        for (Map.Entry<String, Object> entry : info.entrySet()) {
            builder.append(entry.getKey()).append(":").append(Convert.toStr(entry.getValue())).append(LINEARISED);
        }
        builder.append(String.format(SPLIT,title));
        return builder.toString();
    }

    public static void main(String[] args) {
        log.info(format("标题",new JSONObject().set("test","ew")));
    }
}
